package com.payment.ktb.activity.main2;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;

import com.payment.ktb.R;
import com.payment.ktb.activity.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by syd on 2016/11/16.
 */
public class ShopActivity extends BaseActivity {

    String shoppingUrl = "http://mob10.wifenxiao.com/Shop/index/sid/4019089.html?pid=25090858";
    //    String  shoppingUrl = "http://m.haidaowang.com/index.html#back_flag";

    //String  shoppingUrl = "http://mob10.wifenxiao.com/Shop/index/sid/4019089.html?pid=25090858";
    //String  shoppingUrl = "http://m.haidaowang.com";



    @BindView(R.id.wb_shop)
    WebView wb_shop;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shop);
        ButterKnife.bind(this);
        initTitle("商城");
        wb_shop.loadUrl(shoppingUrl);
        //支持js
        wb_shop.getSettings().setJavaScriptEnabled(true);
        //解决显示不全的问题
        wb_shop.getSettings().setDomStorageEnabled(true);
        wb_shop.setWebViewClient(new HelloWebViewClient());
        LinearLayout llBack = (LinearLayout) findViewById(R.id.ll_title_back);
        llBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    private class HelloWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
        }
    }

}
